package com.my.attendance.dao;

import com.my.attendance.entity.Department;
import com.my.attendance.util.BaseDAO;

import java.util.List;

public class DepartmentDao extends BaseDAO {

    public List<Department> getDepartmentList() throws Exception {
        String sql="select * from department;";
        List<Department> departmentList = getList(sql, new Department(), new Object[0]);
        return departmentList;
    }

    public Department getDepartment(int department_number) throws Exception {
        String sql="select * from department where department_number=?;";
        Object[] obj={department_number};
        Department department = getOne(sql, new Department(), obj);
        return department;
    }

    public int updateDepartment(int employee_number,int department_number) throws Exception {
        String sql="update department set department_number=? where employee_number=?";
        Object[] obj={department_number,employee_number};
        int i = addOrupdOrdel(sql, obj);
        return i;
    }
}
